package cn.stylefeng.guns.modular.demo.enums;

import cn.hutool.core.util.RandomUtil;

public enum SaleStockTypeEnum {
    //报损
    BD("damage", "BD", 2), //采购
    CD("supplier", "CD", 1, "CY", "CD"), //调剂
    MD("MD", "MD", 1), ND("ND", "ND", 2), //门店销售
    LS("sale", "LS", 1, "SD", "SD"),
    LT("sale", "LT", 1, "SD", "SD"),
    LX("sale", "LX", 1, "SD", "SD"), //配送
    PD("store", "PD", 2, "CY", "PD"),
    TD("store", "TD", 1, "CY", "PD"), //批发销售
    XD("XD", "XD", 1), //批发销售退货
    ED("ED", "ED", 1), //损益
    SY("SY", "SY", 2), //退货
    GD("supplier", "GD", 2), //自用
    ZD("ZD", "ZD", 0), OD("OD", "OD", 0), OB("OB", "OB", 0), YD("YD", "YD", 0),
    ;
    private String type;
    private String yaodeType;
    // 1 入库 2退货
    private int saleType;
    private String billNoPrefix;
    private String poNoPrefix;

    SaleStockTypeEnum(String type, String yaodeType, int saleType, String billNoPrefix, String poNoPrefix) {
        this.type = type;
        this.yaodeType = yaodeType;
        this.saleType = saleType;
        this.billNoPrefix = billNoPrefix;
        this.poNoPrefix = poNoPrefix;
    }

    SaleStockTypeEnum(String type, String yaodeType, int saleType) {
        this.type = type;
        this.yaodeType = yaodeType;
        this.saleType = saleType;
    }

    public static SaleStockTypeEnum getByType(String type) {
        for (SaleStockTypeEnum value : SaleStockTypeEnum.values()) {
            if (value.getType().equals(type)) {
                return value;
            }
        }
        return null;
    }

    public static SaleStockTypeEnum getByYaodeType(String yaodeType) {
        for (SaleStockTypeEnum value : SaleStockTypeEnum.values()) {
            if (value.getYaodeType().equals(yaodeType)) {
                return value;
            }
        }
        return null;
    }

    public static String randomBillNo(SaleStockTypeEnum saleStockTypeEnum, String time) {
        return saleStockTypeEnum.getBillNoPrefix() + time + RandomUtil.randomInt(4);
    }


    public String getBillNoPrefix() {
        return billNoPrefix;
    }

    public void setBillNoPrefix(String billNoPrefix) {
        this.billNoPrefix = billNoPrefix;
    }

    public String getPoNoPrefix() {
        return poNoPrefix;
    }

    public void setPoNoPrefix(String poNoPrefix) {
        this.poNoPrefix = poNoPrefix;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getYaodeType() {
        return yaodeType;
    }

    public void setYaodeType(String yaodeType) {
        this.yaodeType = yaodeType;
    }

    public int getSaleType() {
        return saleType;
    }

    public void setSaleType(int saleType) {
        this.saleType = saleType;
    }
}
